package org.springblade.modules.task;

import org.springframework.context.annotation.Configuration;
import org.springframework.scheduling.annotation.EnableScheduling;

@Configuration
@EnableScheduling
public class HuodongTask {
//
//    @Autowired
//    private IHuodongService huodongService;
//    @Autowired
//    private IHuodongUsersService huodongUsersService;

//    @Scheduled(cron = "0 0 8 1/1 * ?")
//    public void configureTasks() {
//        //1.查询今天的所有的活动
//        LambdaQueryWrapper<Huodong> queryWrapper = new LambdaQueryWrapper<>();
//        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
//        String currentDate = sdf.format(new Date());
//        queryWrapper.and(wrapper -> wrapper.eq(Huodong::getStime, currentDate));
//        List<Huodong> list = huodongService.list(queryWrapper);
//        //根据活动查询参与人员
//        for (Huodong entity : list) {
//            LambdaQueryWrapper<HuodongUsers> queryUsersWrapper = new LambdaQueryWrapper<>();
//            queryUsersWrapper.and(wrapper -> wrapper.eq(HuodongUsers::getTeamid, entity.getId()));
//            List<HuodongUsers> huodongUsers = huodongUsersService.list(queryUsersWrapper);
//            for (HuodongUsers hdusers : huodongUsers) {
//                try {
//                    MessageUtil.sendBatchMessage(MessageTemplate.smsHuodongStartNotice(entity.getHdname(), sdf.format(entity.getStime()), entity.getAddress()), hdusers.getPhone());
//                } catch (Exception e) {
//                    e.printStackTrace();
//                }
//            }
//
//        }
//
//        System.err.println("执行静态定时任务时间: " + LocalDateTime.now());
//    }
}
